// ============================== h2socket.h ==================================
//
#pragma once

#include <windows.h>
#include <winsock.h>
#include "h2base.h"
#include "h2socket.h"

class h2server
{
public:
    h2server()                                          { _socket = NULL; }
    ~h2server()                                         { close(); }
    void            set_server_ip(const char *ip)       { _ip = inet_addr(ip); }
    void	        set_server_port(int port)           { _port = port; };

	bool		    listen();							// Listen socket
	void		    close();						    // Close server
	bool		    accept_ready(int wait_ms = 0);	    // Check new connection
	bool		    accept(h2socket* ph2socket);	    // Accept new connection

private:
    SOCKET		    _socket;                            // socket handle
	int			    _port;                              // server port
	unsigned long   _ip;                                // server IP
};
